<template>
  <el-row class="lp_header_main">
    <el-col :span="2.5">
      <div class="lp_logo">
        <img :src="avatar"/>
      </div>
    </el-col>
    <el-col :span="21" class="lp_header_right">
      <div class="topbar-title">
        <span style="font-size: 16px;color: #fff;margin-left:20px">催收云管理系统</span>
      </div>
      <div class="lp_header_left">
        <div class="lp_img">
          <img
            src="http://d.hiphotos.baidu.com/image/h%3D300/sign=080742560423dd543e73a168e109b3df/50da81cb39dbb6fd9172db140424ab18972b37d2.jpg"/>
        </div>
        <div style="margin-left: 10px">{{nickname}}</div>
        <div style="margin-left: 20px" class="topbar-account topbar-btn">
          <el-dropdown trigger="click">
            <span><i style="font-size: 26px;vertical-align:middle;color: #f4f4f5;margin-top: -4px"
                     class="el-icon-setting"></i> </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>
                <div @click="jumpTo('/sys/profile')"><span style="color: #555;font-size: 14px;">个人信息</span></div>
              </el-dropdown-item>
              <el-dropdown-item>
                <div @click="jumpTo('/sys/changepwd/1')"><span style="color: #555;font-size: 14px;">修改密码</span></div>
              </el-dropdown-item>
              <el-dropdown-item divided @click.native="logout">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
        <div style="margin-left: 10px" @click="logout">退出</div>
      </div>
    </el-col>
  </el-row>
</template>
<script>
  import assets from '@/assets/icon-blue.png'

  export default {
    name: 'lpHeaderMain',
    data() {
      return {
        nickname: '',
        avatar: assets
      }
    },
    methods: {
      logout() {
        let that = this;
        this.$confirm('确认退出吗?', '提示', {
          confirmButtonClass: 'el-button--warning'
        }).then(() => {
          //确认
          that.loading = true;
          localStorage.clear()
          window.location.reload()
          // that.$router.push('/login');
          // API.logout().then(function (result) {
          //   that.loading = false;
          //   localStorage.removeItem('access-sys');
          //   that.$router.go('/login'); //用go刷新
          // }, function (err) {
          //   that.loading = false;
          //   that.$message.error({showClose: true, message: err.toString(), duration: 2000});
          // }).catch(function (error) {
          //   that.loading = false;
          //   console.log(error);
          //   that.$message.error({showClose: true, message: '请求出现异常', duration: 2000});
          // });
        }).catch(() => {
        });
      },
      jumpTo(url) {
        this.defaultActiveIndex = url;
        this.$router.push(url); //用go刷新
      }
    },
    mounted() {
      let user = window.localStorage.getItem('loginUserInfo')
      this.nickname = JSON.parse(user).realName
    }
  }
</script>
<style scoped lang="scss">
  .lp_header_main {
    height: 68px;
    width: 100%;
    background-color: #333744;
    color: #ffffff;
    line-height: 68px;
    .lp_logo {
      height: 68px;
      width: 200px;
      img {
        padding: 10px;
        max-width: 100%;
        max-height: 75%;
        width: 180px;
      }
    }
    .lp_header_right {
      div {
        display: inline;
        text-align: center;
      }
    }
    .lp_header_left {
      float: right;
      padding-right: 20px;
      font-size: 16px;
      .lp_img {
        border-radius: 5px;
      }
      img {
        vertical-align: middle;
        width: 40px;
        height: 40px;
        border-radius: 40px;
      }
    }
  }
</style>
